<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\admin\common\AdminController;

class Index extends AdminController
{
    public function index()
    {
        $index_count['module'] = model('Admin/Module')->count();
        $index_count['addon']  = 0;//model('Admin/Addon')->count();
        $index_count['users']  = model('Admin/User')->count();

        // 查询今天注册用户
        $start_date = strtotime(date('Y-m-d', time())); //今天
        $end_date = $start_date + 86400;
        $map['create_time'] = array(
            array('egt', $start_date),
            array('lt', $end_date),
        );
        $index_count['today'] = model('Admin/User')->where($map)->count();

        // 查询实时在线用户
        $con = array();
        $con['update_time'] = array('gt', time() - 180);
        $con['uid'] = array('gt', 0);
        $index_count['online'] = \think\Db::name('admin_session')->where($con)->count();

        // 模板赋值
        $this->assign('index_count', $index_count);
        $this->assign('meta_title', "首页");
        $this->display('index/index');
    }
}
